<template>
	<view>
		<u-navbar :title="title"></u-navbar>
		<web-view :webview-styles="webviewStyles" :src="webviewUrl"></web-view>
	</view>
</template>
<script>
import {jsonToUrlParams} from "../../utils";

export default {
	data() {
		return {
			webviewUrl: '',
			title: '',
			webviewStyles: {
				progress: {
					color: '#2b85e4'
				}
			}
		};
	},
	onLoad(options) {
		// 参数不能直接作为参数跟在url后面 小程序里面会失效
		if (options.url) {
			if (options.params) {
				this.webviewUrl = options.url + "?" + jsonToUrlParams(JSON.parse(options.params))
			}else{
				this.webviewUrl = options.url;
			}
		}
		if (options.title) {
			this.title = options.title
		}
		console.log(this.webviewUrl)
	}
};
</script>
<style lang="scss">

</style>
